const app = getApp();
const baseURL = app.globalData.baseURL

Page({
  data: {
    user: {}
  },
  submit() {
    console.log(this.data.user);
    wx.request({
      url: `${baseURL}/user/user/update`,
      method: 'POST',
      data: this.data.user,
      header: {
        "Authorization": 'Bearer ' + wx.getStorageSync('token')
      },
      success: (res) => {
        if(res.data.code==200) {
          wx.showToast({
            title: '修改成功',
          })
        }
      }
    })
  },
  userGenderChange(e) {
    console.log(e.detail.value);
  },
  userAddressInput(e) {
    this.data.user.userAddress = e.detail.value
  },
  userPhoneInput(e) {
    this.data.user.userPhone = e.detail.value
  },
  userAgeInput(e) {
    this.data.user.userAge = e.detail.value
  },
  userNameInput(e) {
    this.data.user.userName = e.detail.value
  },
  onLoad(option) {
    wx.request({
      url: `${baseURL}/user/user/selOne`,
      method: 'POST',
      header: {
        "Authorization": 'Bearer ' + wx.getStorageSync('token')
      },
      success: (res) => {
        this.setData({
          user: res.data.data
        })
      }
    })
  }
})